//  路由白名单
let writelist: any[] = ["index", "download", "activity", "business", "404"];
export default defineNuxtRouteMiddleware(async (to:any, from) => {
    if (process.client) {
        const store = useStore();
        let istoken = computed(() => store.token);
        // if (store.userinfo.gameID != "") {
        //   GetUserInfo(store.userinfo).then(({ data }: { data: any }) => {
        //     store.$patch({ coininfo: data.value.data.accounts });
        //   });
        // }
    
        if (!writelist.includes(to.name)) {
          //校验是否有token
          if (
            istoken.value == "" ||
            istoken.value == null ||
            istoken.value == undefined
          ) {
            store.$patch({ loginopen: true });
            return abortNavigation("No permission temporarily");
          }
        }
      } else {
        // const store = useStore();
        // let istoken = computed(() => store.token);
        // // console.log(istoken.value, !writelist.includes(to.name), "istoken");
        // if (!writelist.includes(to.name)) {
        //   //校验是否有token
        //   if (
        //     istoken.value == "" ||
        //     istoken.value == null ||
        //     istoken.value == undefined
        //   ) {
        //     // store.$patch({ loginopen: true });
        //     return  navigateTo("/404");
        //   }
        // }
      }
});
